const config = require('./config/index.js');
const path = require('path');
const apiMocker = require('mocker-api');

module.exports = {
    publicPath: process.env.NODE_ENV === 'production' ? config.staticPath : undefined,
    runtimeCompiler: true,
    chainWebpack: (config) => {
        config.resolve.alias
            .set('@', path.join(__dirname, 'src'))
            .set('assets', path.join(__dirname, 'src/assets'));
        config.devServer
            .set('before', (app) => {
                apiMocker(app, path.resolve('./mock/index.js'), {
                    changeHost: true,
                });
            })
            .set('inline', true)
            // .set('host', 'localhost')
            .set('compress', true)
            .set('hot', true)
            .set('port', 8080)
            .set('open', true)
            .set('watchOptions', {
                poll: true,
                ignored: /node_modules/
            });
    },
};
